1 Imports System.Data.SqlClient
2 Imports System.IO
3 Imports Excel = Microsoft.Office.Interop.Excel
4 Public Class frmStudentRecord
5 Public Sub GetData()
6 Try
7 con = New SqlConnection(cs)
8 con.Open()
9 cmd = New SqlCommand("Select RTRIM(AdmissionNo) as [Admission No],RTRIM(EnrollmentNo) as [Enrollment No], RTRIM(GRNo) as [GR No], RTRIM(UID) as [UID],Convert(DateTime,AdmissionDate,103) as [Admission Date], RTRIM(StudentName) as [Student Name], RTRIM(Gender) as [Gender],Convert(DateTime,DOB,103) as [DOB],RTRIM(Session) as Session,RTRIM(Caste) as [Category],RTRIM(Religion) as [Religion],RTRIM(FatherName) as [Father's Name], RTRIM(FatherCN) as [Father's CN], RTRIM(MotherName) as [Mother's Name],RTRIM(PermanentAddress) as [Permanent Address], RTRIM(TemporaryAddress) as [Temporary Address], RTRIM(Student.ContactNo) as [Contact No], RTRIM(EmailID) as [Email ID],RTRIM(SectionID) as [Section ID],RTRIM(ClassName) as [Class],RTRIM(SectionName) as Section,RTRIM(SchoolID) as [School ID],RTRIM(SchoolName) as [School Name],RTRIM(LastSchoolAttended) as [Last School Attended],RTRIM(Result) as [Result],RTRIM(PassPerCentage) as [If Pass then %],RTRIM(Nationality) as [Nationality],RTRIM(Status) as [Status],Photo from Student,Class,Section,SchoolInfo where Student.SectionID=Section.ID and Class.ClassName=Section.Class and SchoolInfo.S_ID=Student.SchoolID order by StudentName", con)
10 adp = New SqlDataAdapter(cmd)
11 ds = New DataSet()
12 adp.Fill(ds, "Student")
13 dgw.DataSource = ds.Tables("Student").DefaultView
14 con.Close()
15 Catch ex As Exception
16 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
17 End Try
18 End Sub
19
20 Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
21 Me.Close()
22 End Sub
23
24 Private Sub txtStudentName_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtStudentName.TextChanged
25 Try
26 con = New SqlConnection(cs)
27 con.Open()
28 cmd = New SqlCommand("Select RTRIM(AdmissionNo) as [Admission No],RTRIM(EnrollmentNo) as [Enrollment No], RTRIM(GRNo) as [GR No], RTRIM(UID) as [UID],Convert(DateTime,AdmissionDate,103) as [Admission Date], RTRIM(StudentName) as [Student Name], RTRIM(Gender) as [Gender],Convert(DateTime,DOB,103) as [DOB],RTRIM(Session) as Session,RTRIM(Caste) as [Category],RTRIM(Religion) as [Religion],RTRIM(FatherName) as [Father's Name], RTRIM(FatherCN) as [Father's CN], RTRIM(MotherName) as [Mother's Name],RTRIM(PermanentAddress) as [Permanent Address], RTRIM(TemporaryAddress) as [Temporary Address], RTRIM(Student.ContactNo) as [Contact No], RTRIM(EmailID) as [Email ID],RTRIM(SectionID) as [Section ID],RTRIM(ClassName) as [Class],RTRIM(SectionName) as Section,RTRIM(SchoolID) as [School ID],RTRIM(SchoolName) as [School Name],RTRIM(LastSchoolAttended) as [Last School Attended],RTRIM(Result) as [Result],RTRIM(PassPerCentage) as [If Pass then %],RTRIM(Nationality) as [Nationality],RTRIM(Status) as [Status],Photo from Student,Class,Section,SchoolInfo where Student.SectionID=Section.ID and Class.ClassName=Section.Class and SchoolInfo.S_ID=Student.SchoolID and StudentName like '" & txtStudentName.Text & "%' order by StudentName", con)
29 adp = New SqlDataAdapter(cmd)
30 ds = New DataSet()
31 adp.Fill(ds, "Student")
32 dgw.DataSource = ds.Tables("Student").DefaultView
33 con.Close()
34 Catch ex As Exception
35 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
36 End Try
37 End Sub
38
39 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
40 Try
41 con = New SqlConnection(cs)
42 con.Open()
43 cmd = New SqlCommand("Select RTRIM(AdmissionNo) as [Admission No],RTRIM(EnrollmentNo) as [Enrollment No], RTRIM(GRNo) as [GR No], RTRIM(UID) as [UID],Convert(DateTime,AdmissionDate,103) as [Admission Date], RTRIM(StudentName) as [Student Name], RTRIM(Gender) as [Gender],Convert(DateTime,DOB,103) as [DOB],RTRIM(Session) as Session,RTRIM(Caste) as [Category],RTRIM(Religion) as [Religion],RTRIM(FatherName) as [Father's Name], RTRIM(FatherCN) as [Father's CN], RTRIM(MotherName) as [Mother's Name],RTRIM(PermanentAddress) as [Permanent Address], RTRIM(TemporaryAddress) as [Temporary Address], RTRIM(Student.ContactNo) as [Contact No], RTRIM(EmailID) as [Email ID],RTRIM(SectionID) as [Section ID],RTRIM(ClassName) as [Class],RTRIM(SectionName) as Section,RTRIM(SchoolID) as [School ID],RTRIM(SchoolName) as [School Name],RTRIM(LastSchoolAttended) as [Last School Attended],RTRIM(Result) as [Result],RTRIM(PassPerCentage) as [If Pass then %],RTRIM(Nationality) as [Nationality],RTRIM(Status) as [Status],Photo from Student,Class,Section,SchoolInfo where Student.SectionID=Section.ID and Class.ClassName=Section.Class and SchoolInfo.S_ID=Student.SchoolID and Session=@d1 and ClassName=@d2 and SectionName=@d3 order by StudentName", con)
44 cmd.Parameters.AddWithValue("@d1", cmbSession.Text)
45 cmd.Parameters.AddWithValue("@d2", cmbClass.Text)
46 cmd.Parameters.AddWithValue("@d3", cmbSection.Text)
47 adp = New SqlDataAdapter(cmd)
48 ds = New DataSet()
49 adp.Fill(ds, "Student")
50 dgw.DataSource = ds.Tables("Student").DefaultView
51 con.Close()
52 Catch ex As Exception
53 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
54 End Try
55 End Sub
56
57 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
58 Try
59 con = New SqlConnection(cs)
60 con.Open()
61 cmd = New SqlCommand("Select RTRIM(AdmissionNo) as [Admission No],RTRIM(EnrollmentNo) as [Enrollment No], RTRIM(GRNo) as [GR No], RTRIM(UID) as [UID],Convert(DateTime,AdmissionDate,103) as [Admission Date], RTRIM(StudentName) as [Student Name], RTRIM(Gender) as [Gender],Convert(DateTime,DOB,103) as [DOB],RTRIM(Session) as Session,RTRIM(Caste) as [Category],RTRIM(Religion) as [Religion],RTRIM(FatherName) as [Father's Name], RTRIM(FatherCN) as [Father's CN], RTRIM(MotherName) as [Mother's Name],RTRIM(PermanentAddress) as [Permanent Address], RTRIM(TemporaryAddress) as [Temporary Address], RTRIM(Student.ContactNo) as [Contact No], RTRIM(EmailID) as [Email ID],RTRIM(SectionID) as [Section ID],RTRIM(ClassName) as [Class],RTRIM(SectionName) as Section,RTRIM(SchoolID) as [School ID],RTRIM(SchoolName) as [School Name],RTRIM(LastSchoolAttended) as [Last School Attended],RTRIM(Result) as [Result],RTRIM(PassPerCentage) as [If Pass then %],RTRIM(Nationality) as [Nationality],RTRIM(Status) as [Status],Photo from Student,Class,Section,SchoolInfo where Student.SectionID=Section.ID and Class.ClassName=Section.Class and SchoolInfo.S_ID=Student.SchoolID and AdmissionDate between @d1 and @d2 order by StudentName", con)
62 cmd.Parameters.Add("@d1", SqlDbType.DateTime, 30, "Date").Value = dtpDateFrom.Value.Date
63 cmd.Parameters.Add("@d2", SqlDbType.DateTime, 30, "Date").Value = dtpDateTo.Value.Date
64 adp = New SqlDataAdapter(cmd)
65 ds = New DataSet()
66 adp.Fill(ds, "Student")
67 dgw.DataSource = ds.Tables("Student").DefaultView
68 con.Close()
69 Catch ex As Exception
70 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
71 End Try
72 End Sub
73
74 Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
75 Try
76 con = New SqlConnection(cs)
77 con.Open()
78 cmd = New SqlCommand("Select RTRIM(AdmissionNo) as [Admission No],RTRIM(EnrollmentNo) as [Enrollment No], RTRIM(GRNo) as [GR No], RTRIM(UID) as [UID],Convert(DateTime,AdmissionDate,103) as [Admission Date], RTRIM(StudentName) as [Student Name], RTRIM(Gender) as [Gender],Convert(DateTime,DOB,103) as [DOB],RTRIM(Session) as Session,RTRIM(Caste) as [Category],RTRIM(Religion) as [Religion],RTRIM(FatherName) as [Father's Name], RTRIM(FatherCN) as [Father's CN], RTRIM(MotherName) as [Mother's Name],RTRIM(PermanentAddress) as [Permanent Address], RTRIM(TemporaryAddress) as [Temporary Address], RTRIM(Student.ContactNo) as [Contact No], RTRIM(EmailID) as [Email ID],RTRIM(SectionID) as [Section ID],RTRIM(ClassName) as [Class],RTRIM(SectionName) as Section,RTRIM(SchoolID) as [School ID],RTRIM(SchoolName) as [School Name],RTRIM(LastSchoolAttended) as [Last School Attended],RTRIM(Result) as [Result],RTRIM(PassPerCentage) as [If Pass then %],RTRIM(Nationality) as [Nationality],RTRIM(Status) as [Status],Photo from Student,Class,Section,SchoolInfo where Student.SectionID=Section.ID and Class.ClassName=Section.Class and SchoolInfo.S_ID=Student.SchoolID and Classname=@d1 and Caste=@d2 order by StudentName", con)
79 cmd.Parameters.AddWithValue("@d1", cmbClass1.Text)
80 cmd.Parameters.AddWithValue("@d2", cmbCategory.Text)
81 adp = New SqlDataAdapter(cmd)
82 ds = New DataSet()
83 adp.Fill(ds, "Student")
84 dgw.DataSource = ds.Tables("Student").DefaultView
85 con.Close()
86 Catch ex As Exception
87 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
88 End Try
89 End Sub
90 Sub fillSession()
91 Try
92 con = New SqlConnection(cs)
93 con.Open()
94 adp = New SqlDataAdapter()
95 adp.SelectCommand = New SqlCommand("SELECT distinct (Session) FROM Student", con)
96 ds = New DataSet("ds")
97 adp.Fill(ds)
98 dtable = ds.Tables(0)
99 cmbSession.Items.Clear()
100 For Each drow As DataRow In dtable.Rows
101 cmbSession.Items.Add(drow(0).ToString())
102 Next
103 Catch ex As Exception
104 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
105 End Try
106 End Sub
107 Sub fillClass()
108 Try
109 con = New SqlConnection(cs)
110 con.Open()
111 adp = New SqlDataAdapter()
112 adp.SelectCommand = New SqlCommand("SELECT distinct (ClassName) FROM Student,Section,Class where Student.SectionID=Section.ID and Section.Class=Class.Classname", con)
113 ds = New DataSet("ds")
114 adp.Fill(ds)
115 dtable = ds.Tables(0)
116 cmbClass1.Items.Clear()
117 For Each drow As DataRow In dtable.Rows
118 cmbClass1.Items.Add(drow(0).ToString())
119 Next
120 Catch ex As Exception
121 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
122 End Try
123 End Sub
124
125 Private Sub cmbSession_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbSession.SelectedIndexChanged
126 Try
127 cmbClass.Enabled = True
128 con = New SqlConnection(cs)
129 con.Open()
130 Dim ct As String = "SELECT distinct RTRIM(ClassName) FROM Student,Section,Class where Student.SectionID=Section.ID and Section.Class=Class.ClassName and Session=@d1"
131 cmd = New SqlCommand(ct)
132 cmd.Connection = con
133 cmd.Parameters.AddWithValue("@d1", cmbSession.Text)
134 rdr = cmd.ExecuteReader()
135 cmbClass.Items.Clear()
136 While rdr.Read
137 cmbClass.Items.Add(rdr(0))
138 End While
139 con.Close()
140 Catch ex As Exception
141 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
142 End Try
143
144 End Sub
145
146 Private Sub cmbClass_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbClass.SelectedIndexChanged
147 Try
148 cmbSection.Enabled = True
149 con = New SqlConnection(cs)
150 con.Open()
151 Dim ct As String = "SELECT distinct RTRIM(SectionName) FROM Student,Section,Class where Student.SectionID=Section.ID and Section.Class=Class.ClassName and Session=@d1 and ClassName=@d2"
152 cmd = New SqlCommand(ct)
153 cmd.Connection = con
154 cmd.Parameters.AddWithValue("@d1", cmbSession.Text)
155 cmd.Parameters.AddWithValue("@d2", cmbClass.Text)
156 rdr = cmd.ExecuteReader()
157 cmbSection.Items.Clear()
158 While rdr.Read
159 cmbSection.Items.Add(rdr(0))
160 End While
161 con.Close()
162 Catch ex As Exception
163 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
164 End Try
165 End Sub
166
167 Private Sub txtAdmissionNo_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtAdmissionNo.TextChanged
168 Try
169 con = New SqlConnection(cs)
170 con.Open()
171 cmd = New SqlCommand("Select RTRIM(AdmissionNo) as [Admission No],RTRIM(EnrollmentNo) as [Enrollment No], RTRIM(GRNo) as [GR No], RTRIM(UID) as [UID],Convert(DateTime,AdmissionDate,103) as [Admission Date], RTRIM(StudentName) as [Student Name], RTRIM(Gender) as [Gender],Convert(DateTime,DOB,103) as [DOB],RTRIM(Session) as Session,RTRIM(Caste) as [Category],RTRIM(Religion) as [Religion],RTRIM(FatherName) as [Father's Name], RTRIM(FatherCN) as [Father's CN], RTRIM(MotherName) as [Mother's Name],RTRIM(PermanentAddress) as [Permanent Address], RTRIM(TemporaryAddress) as [Temporary Address], RTRIM(Student.ContactNo) as [Contact No], RTRIM(EmailID) as [Email ID],RTRIM(SectionID) as [Section ID],RTRIM(ClassName) as [Class],RTRIM(SectionName) as Section,RTRIM(SchoolID) as [School ID],RTRIM(SchoolName) as [School Name],RTRIM(LastSchoolAttended) as [Last School Attended],RTRIM(Result) as [Result],RTRIM(PassPerCentage) as [If Pass then %],RTRIM(Nationality) as [Nationality],RTRIM(Status) as [Status],Photo from Student,Class,Section,SchoolInfo where Student.SectionID=Section.ID and Class.ClassName=Section.Class and SchoolInfo.S_ID=Student.SchoolID and AdmissionNo like '" & txtAdmissionNo.Text & "%' order by StudentName", con)
172 adp = New SqlDataAdapter(cmd)
173 ds = New DataSet()
174 adp.Fill(ds, "Student")
175 dgw.DataSource = ds.Tables("Student").DefaultView
176 con.Close()
177 Catch ex As Exception
178 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
179 End Try
180 End Sub
181 Sub Reset()
182 txtAdmissionNo.Text = ""
183 txtStudentName.Text = ""
184 cmbCategory.SelectedIndex = -1
185 cmbClass.SelectedIndex = -1
186 cmbClass1.SelectedIndex = -1
187 cmbSection.SelectedIndex = -1
188 cmbSession.SelectedIndex = -1
189 txtGRNo.Text = ""
190 cmbClass.Enabled = False
191 cmbSection.Enabled = False
192 dtpDateFrom.Text = Today
193 dtpDateTo.Text = Today
194 GetData()
195 End Sub
196 Private Sub btnReset_Click(sender As System.Object, e As System.EventArgs) Handles btnReset.Click
197 Reset()
198 End Sub
199
200 Private Sub frmStudentRecord_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
201 fillClass()
202 fillSession()
203 GetData()
204 End Sub
205
206 Private Sub dgw_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles dgw.MouseClick
207 Try
208 Dim dr As DataGridViewRow = dgw.SelectedRows(0)
209 If lblSet.Text = "Student Entry" Then
210 Me.Hide()
211 frmStudent.Show()
212 frmStudent.txtAdmissionNo.Text = dr.Cells(0).Value.ToString()
213 frmStudent.txtAdmissionNo1.Text = dr.Cells(0).Value.ToString()
214 frmStudent.txtEnrollmentNo.Text = dr.Cells(1).Value.ToString()
215 frmStudent.txtGRNo.Text = dr.Cells(2).Value.ToString()
216 frmStudent.txtUID.Text = dr.Cells(3).Value.ToString()
217 frmStudent.dtpAdmissionDate.Text = dr.Cells(4).Value.ToString()
218 frmStudent.txtStudentName.Text = dr.Cells(5).Value.ToString()
219 If (dr.Cells(6).Value = "Male") Then
220 frmStudent.rbMale.Checked = True
221 End If
222 If (dr.Cells(6).Value = "female") Then
223 frmStudent.rbFemale.Checked = True
224 End If
225 frmStudent.dtpDOB.Text = dr.Cells(7).Value.ToString()
226 frmStudent.cmbSession.Text = dr.Cells(8).Value.ToString()
227 frmStudent.cmbCategory.Text = dr.Cells(9).Value.ToString()
228 frmStudent.cmbReligion.Text = dr.Cells(10).Value.ToString()
229 frmStudent.txtFathername.Text = dr.Cells(11).Value.ToString()
230 frmStudent.txtFatherContactNo.Text = dr.Cells(12).Value.ToString()
231 frmStudent.txtMotherName.Text = dr.Cells(13).Value.ToString()
232 frmStudent.txtPermanentAddress.Text = dr.Cells(14).Value.ToString()
233 frmStudent.txtTemrorayAddress.Text = dr.Cells(15).Value.ToString()
234 frmStudent.txtContactNo.Text = dr.Cells(16).Value.ToString()
235 frmStudent.txtEmailID.Text = dr.Cells(17).Value.ToString()
236 frmStudent.txtSectionID.Text = dr.Cells(18).Value.ToString()
237 frmStudent.txtClass.Text = dr.Cells(19).Value.ToString()
238 frmStudent.txtSection.Text = dr.Cells(20).Value.ToString()
239 frmStudent.txtSchoolID.Text = dr.Cells(21).Value.ToString()
240 frmStudent.cmbSchoolName.Text = dr.Cells(22).Value.ToString()
241 frmStudent.txtLastSchoolAttended.Text = dr.Cells(23).Value.ToString()
242 frmStudent.cmbResult.Text = dr.Cells(24).Value.ToString()
243 frmStudent.txtPercentage.Text = dr.Cells(25).Value.ToString()
244 frmStudent.txtNationality.Text = dr.Cells(26).Value.ToString()
245 frmStudent.cmbStatus.Text = dr.Cells(27).Value.ToString()
246 Dim data As Byte() = DirectCast(dr.Cells(28).Value, Byte())
247 Dim ms As New MemoryStream(data)
248 frmStudent.Picture.Image = Image.FromStream(ms)
249 con = New SqlConnection(cs)
250 con.Open()
251 cmd = New SqlCommand("SELECT DocID,DocName from Student,Document,StudentDocSubmitted where Student.AdmissionNo=StudentDocSubmitted.AdmissionNo and Document.Doc_ID=StudentDocSubmitted.DocID and Student.AdmissionNo=@d1", con)
252 cmd.Parameters.AddWithValue("@d1", dr.Cells(0).Value)
253 rdr = cmd.ExecuteReader()
254 While rdr.Read()
255
256 Dim lst As New ListViewItem()
257 lst.SubItems.Add(rdr(0))
258 lst.SubItems.Add(rdr(1).ToString().Trim())
259 frmStudent.ListView1.Items.Add(lst)
260 End While
261 frmStudent.btnDelete.Enabled = True
262 frmStudent.btnUpdate.Enabled = True
263 frmStudent.btnSave.Enabled = False
264 con = New SqlConnection(cs)
265 con.Open()
266 cmd = con.CreateCommand()
267 cmd.CommandText = "SELECT Session FROM Student where AdmissionNo=@d1"
268 cmd.Parameters.AddWithValue("@d1", dr.Cells(0).Value)
269 rdr = cmd.ExecuteReader()
270 If rdr.Read() Then
271 frmStudent.cmbSession.Text = rdr.GetValue(0)
272 End If
273 If (rdr IsNot Nothing) Then
274 rdr.Close()
275 End If
276 If con.State = ConnectionState.Open Then
277 con.Close()
278 End If
279 lblSet.Text = ""
280 End If
281 If lblSet.Text = "Hosteler Entry" Then
282 Me.Hide()
283 frmHosteler.Show()
284 frmHosteler.txtAdmissionNo.Text = dr.Cells(0).Value.ToString()
285 frmHosteler.txtStudentName.Text = dr.Cells(5).Value.ToString()
286 frmHosteler.txtClass.Text = dr.Cells(19).Value.ToString()
287 frmHosteler.txtSection.Text = dr.Cells(20).Value.ToString()
288 frmHosteler.txtSchoolName.Text = dr.Cells(22).Value.ToString()
289 End If
290 If lblSet.Text = "Bus Holder Entry" Then
291 Me.Hide()
292 frmBusCardHolder_Student.Show()
293 frmBusCardHolder_Student.txtAdmissionNo.Text = dr.Cells(0).Value.ToString()
294 frmBusCardHolder_Student.txtStudentName.Text = dr.Cells(5).Value.ToString()
295 frmBusCardHolder_Student.txtClass.Text = dr.Cells(19).Value.ToString()
296 frmBusCardHolder_Student.txtSection.Text = dr.Cells(20).Value.ToString()
297 frmBusCardHolder_Student.txtSchoolName.Text = dr.Cells(22).Value.ToString()
298 End If
299 If lblSet.Text = "Course Fee Payment" Then
300 Me.Hide()
301 frmCourseFeePayment.Show()
302 frmCourseFeePayment.txtAdmissionNo.Text = dr.Cells(0).Value.ToString()
303 frmCourseFeePayment.txtEnrollmentNo.Text = dr.Cells(1).Value.ToString()
304 frmCourseFeePayment.txtStudentName.Text = dr.Cells(5).Value.ToString()
305 frmCourseFeePayment.txtClass.Text = dr.Cells(19).Value.ToString()
306 frmCourseFeePayment.txtSection.Text = dr.Cells(20).Value.ToString()
307 frmCourseFeePayment.txtSchoolName.Text = dr.Cells(22).Value.ToString()
308 frmCourseFeePayment.txtSession.Text = dr.Cells(8).Value.ToString()
309 frmCourseFeePayment.FillData()
310 End If
311 Catch ex As Exception
312 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
313 End Try
314 End Sub
315
316 Private Sub dgw_RowPostPaint(sender As Object, e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles dgw.RowPostPaint
317 Dim strRowNumber As String = (e.RowIndex + 1).ToString()
318 Dim size As SizeF = e.Graphics.MeasureString(strRowNumber, Me.Font)
319 If dgw.RowHeadersWidth < Convert.ToInt32((size.Width + 20)) Then
320 dgw.RowHeadersWidth = Convert.ToInt32((size.Width + 20))
321 End If
322 Dim b As Brush = SystemBrushes.ControlText
323 e.Graphics.DrawString(strRowNumber, Me.Font, b, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2))
324
325 End Sub
326
327 Private Sub txtGRNo_TextChanged(sender As Object, e As EventArgs) Handles txtGRNo.TextChanged
328 Try
329 con = New SqlConnection(cs)
330 con.Open()
331 cmd = New SqlCommand("Select RTRIM(AdmissionNo) as [Admission No],RTRIM(EnrollmentNo) as [Enrollment No], RTRIM(GRNo) as [GR No], RTRIM(UID) as [UID],Convert(DateTime,AdmissionDate,103) as [Admission Date], RTRIM(StudentName) as [Student Name], RTRIM(Gender) as [Gender],Convert(DateTime,DOB,103) as [DOB],RTRIM(Session) as Session,RTRIM(Caste) as [Category],RTRIM(Religion) as [Religion],RTRIM(FatherName) as [Father's Name], RTRIM(FatherCN) as [Father's CN], RTRIM(MotherName) as [Mother's Name],RTRIM(PermanentAddress) as [Permanent Address], RTRIM(TemporaryAddress) as [Temporary Address], RTRIM(Student.ContactNo) as [Contact No], RTRIM(EmailID) as [Email ID],RTRIM(SectionID) as [Section ID],RTRIM(ClassName) as [Class],RTRIM(SectionName) as Section,RTRIM(SchoolID) as [School ID],RTRIM(SchoolName) as [School Name],RTRIM(LastSchoolAttended) as [Last School Attended],RTRIM(Result) as [Result],RTRIM(PassPerCentage) as [If Pass then %],RTRIM(Nationality) as [Nationality],RTRIM(Status) as [Status],Photo from Student,Class,Section,SchoolInfo where Student.SectionID=Section.ID and Class.ClassName=Section.Class and SchoolInfo.S_ID=Student.SchoolID and GRNo like '" & txtGRNo.Text & "%' order by StudentName", con)
332 adp = New SqlDataAdapter(cmd)
333 ds = New DataSet()
334 adp.Fill(ds, "Student")
335 dgw.DataSource = ds.Tables("Student").DefaultView
336 con.Close()
337 Catch ex As Exception
338 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
339 End Try
340 End Sub
341 End Class